home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-09-20 | 867 b | 32 lines |
- //
- // an agent raises his hand when you click him.
- //
-
- import vrml.*;
- import vrml.node.*;
- import vrml.field.*;
-
- public class SwitchAgent extends Script{
- SFInt32 setAgentImage;
- boolean normalPosture = true;
-
- public void initialize(){
- // get the reference of the event out 'setAgentImage'.
- setAgentImage = (SFInt32)getEventOut("setAgentImage");
- }
-
- public void processEvent(Event e){
- if(e.getName().equals("touchTime") == true){
- // toggle the state.
- normalPosture = !normalPosture;
- if(true == normalPosture){
- // make the agent in normal posture.
- setAgentImage.setValue(0);
- }else{
- // make the agent in hello posture.
- setAgentImage.setValue(1);
- }
- }
- }
- }
-